if(tasks == undefined) {
    var tasks = {};
}

tasks.task = function() {
    return {
        showEditState : function(id) {
            JsonC.callSfAction('task/showEditState',{id:id});
        },
        showEditDescription : function(id) {
            JsonC.callSfAction('task/showEditDescription',{id:id});
        },
        showEditHowToShow : function(id) {
            JsonC.callSfAction('task/showEditHowToShow',{id:id});
        },
        showEditTechnicalAspects : function(id) {
            JsonC.callSfAction('task/showEditTechnicalAspects',{id:id});
        },
        submitEditStateForm : function() {
            JsonC.submitForSfAction('task/editState',{},'tasks-task-edit-state-form','tasks-task-edit-state-form-loading');
        },
        submitEditDescriptionForm : function() {
            JsonC.submitForSfAction('task/editDescription',{},'tasks-task-edit-description-form','tasks-task-edit-description-form-loading');
        },
        submitEditHowToShowForm : function() {
            JsonC.submitForSfAction('task/editHowToShow',{},'tasks-task-edit-how-to-show-form','tasks-task-edit-how-to-show-form-loading');
        },
        submitEditTechnicalAspectsForm : function() {
            JsonC.submitForSfAction('task/editTechnicalAspects',{},'tasks-task-edit-technical-aspects-form','tasks-task-edit-technical-aspects-form-loading');
        },
        showNodeData : function(json) {
            var params = {id:json.id};
            if (json.tab != undefined) {
                params.tab = json.tab;
            }
            JsonC.callSfAction('task/showNodeData',json);
        },
        displayNodeData : function(json) {
            $('#node-data').html(json.data);
            if(json.tab != undefined) {
                $('#nodeTabs').tabs("select",json.tab);
            }
            console.log(json);
        },
        showRelateTests : function(id) {
            JsonC.callSfAction('task/showRelateTests',{id:id});
        },
        relateTests : function(id) {
            JsonC.submitForSfAction(
                'task/relateTests',
                {taskId:id},
                'testsForm'
            );
        },
        displayNodeContent : function(json) {
            $('#nodeContent').html(json.data);
        },
        displayRelatedTests : function(json) {
            $('#task-related-tests').html(json.data);
        },
        printCards : function() {
            document.location = JsonC.genSfUrl('task/printCards');
        }
    }
}();

